

<template>

    <div class="ubean-warp">
        <div class='ubean-top'>
            <div class='ubean-rule-btn' >活动规则</div>
            <div class='ubean-rule-cover-btn' ></div>
            <p class='ubean-top-title1'>{{balance}}</p>
            <p class='ubean-top-title2'>已有U豆</p>
        </div>
        <div class='ubean-time-limit '>
            <p>U豆收支明细</p>
        </div>

        <div class='ubean-detail-bottom' v-for="item in detailList">
            <div class='flex'>
                <p style='flex:1'>{{item.note}}</p>
                <div style='font-weight:bold' v-if="item.type==1">+{{item.value}} <img  src='http://img.uuuda.com/pullperson/u-logo.png'  style='width:12px;height:12px;' /></div>
                <div style='font-weight:bold' v-if="item.type==2">-{{item.value}} <img  src='http://img.uuuda.com/pullperson/u-logo.png' style='width:12px;height:12px;' /></div>
            </div>
            <div class='ubean-detail-time'>{{item.time}}</div>
        </div>



    </div>


</template>

<script>
    let axios = require("axios");
    export default {
        components: {
        },
        data() {
            return {
                detailList:[],
                balance:0,//余额

            }
        },
        created() {
        },
        mounted(){

           this.initPage();
        },
        watch:{
        },
        methods: {
            //初始化页面
            initPage(){

                let self = this;
                let query = this.$route.query;
                let token = query.u || '';

                axios({
                    method: "POST",
                    url: "/api/ubeans/budgetdetails",
                    params: {
                      'token':token,
                    }
                }).then(function(res) {
                    let rdata = res.data.data;
                    if(res.data.errno == 200){
                        for (let i = 0; i < rdata.recording.length; i++) {
                            rdata.recording[i].time = self.formatDate(rdata.recording[i].time)
                        }
                        self.detailList=rdata.recording;
                        self.balance= rdata.sum;

                    }else {

                    }

                });


            },
             formatDate(datetime) {
                      // 获取年月日时分秒值  slice(-2)过滤掉大于10日期前面的0
                 let dateTime = new Date(datetime*1000);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
                 let year = dateTime.getFullYear(),
                        month = ("0" + (dateTime.getMonth() + 1)).slice(-2),
                        date = ("0" + dateTime.getDate()).slice(-2),
                        hour = ("0" + dateTime.getHours()).slice(-2),
                        minute = ("0" + dateTime.getMinutes()).slice(-2),
                        second = ("0" + dateTime.getSeconds()).slice(-2);
                      // 拼接
                 let result = year + "-"+ month +"-"+ date +" "+ hour +":"+ minute +":" + second;
                       // 返回
                       return result;
                   }

        }
    }
</script>

<style>
    .ubean-warp{
        background: white;
        padding-top:20px;
    }
    .ubean-top{
        position: relative;
        background: url('http://img.uuuda.com/mine/u_bg.png')0 0 no-repeat;
        background-size: 100% 100%;
        width: 90%;
        height: 138px;
        left: 5%;
        margin-top: 20px;
    }
    .ubean-top p{
        display: block;
        font-weight: bold;
        text-align: center;
    }
    .ubean-rule-btn{
        position: absolute;
        right: 8px;
        top:8px;
        border: 2px solid white;
        text-align: center;
        color: white;
        font-size: 12px;
        padding:0px 5px;
    }
    .ubean-rule-cover-btn{
        position: absolute;
        right: 0px;
        top:0px;
        width: 100px;
        height: 50px;
        opacity: 0;
    }

    .ubean-top-title1{
        font-size:36px;
        height: 36px;
        line-height: 36px;
        padding-top: 40px;
        p-align: center;
    }

    .ubean-top-title2{
        font-size: 12px;
        margin-top: 40px;
    }

    .flex{
        display:-webkit-box;
        display:-webkit-flex;
        display:flex;

    }
    /* 中间文案 */
    .ubean-time-limit{
        position: relative;
        width: 100%;
        background: #f5f5f5;
        margin-bottom:12px;
        padding:12px 0;
        overflow: hidden;
        margin-top:12px;
    }
    .ubean-time-limit p{
        display: block;
        font-size:18px;
        color: #1a1a1a;
        font-weight: bold;
        width:90%;
        left:4%;
        position:relative;

    }/* 列表 */
    .ubean-detail-bottom{
        position: relative;
        width:90%;
        left:5%;
        font-size: 16px;
        border-bottom:2px solid #ededed;
        margin-bottom: 16px;
        background: white;
    }
    .ubean-detail-time{
        padding: 8px 0 11px 0;
        color: #999999;
        font-size: 12px;
    }
    .loadTitle{
        color: #949494;
        display: block;
        position: relative;
        height: 50px;
        line-height: 50px;
        font-size: 10px;
        text-align: center;
        background:#f5f5f5
    }

</style>


